package com.ohc.leetcode.链表;

import com.ohc.leetcode.Node;

/**
 * 2022年4月20日14:33:14
 */
public class 环形链表141 {

    public boolean hasCycle(Node head) {
        Node slow = head;
        Node fast = head.next;
        while (slow != fast) {
            if (fast.next != null && fast.next.next != null) {
                fast = fast.next.next;
                slow = slow.next;
            } else {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {

    }
}
